package com.techsoft;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class SQLParam extends HashMap<String, Object> {
	private static final long serialVersionUID = -8425996590683250112L;
	private transient List<Integer> positions;

	public SQLParam() {
		 positions = new ArrayList<Integer>();
	}

	private void buildPositions(String index) {
		positions.clear();
		if ((index == null) || (index.equals(""))) {
			return;
		} else {
			String[] poss = index.split(",");

			for (String item : poss) {
				positions.add(Integer.valueOf(item.trim()));
			}
		}
	}

	public String getDtype() {	
		Object tempdata = this.get("DTYPE");
		if (tempdata != null) {
			return (String) tempdata;
		}
		
		return null;	
	}

	public void setDtype(String dtype) {
		this.put("DTYPE", dtype);
	}

	public String getDtypename() {	
		Object tempdata = this.get("DTYPENAME");
		if (tempdata != null) {
			return (String) tempdata;
		}
		
		return null;	
	}

	public void setDtypename(String dtypename) {
		this.put("DTYPENAME", dtypename);
	}

	public String getIndex() {	
		Object tempdata = this.get("INDEX");
		if (tempdata != null) {
			return (String) tempdata;
		}
		
		return null;	
	}

	public void setIndex(String index) {
		if (!index.equalsIgnoreCase(this.getIndex())) {
			this.put("INDEX", index);
			this.buildPositions(index);
		}
	}

	public String getIotype() {	
		Object tempdata = this.get("IOTYPE");
		if (tempdata != null) {
			return (String) tempdata;
		}
		
		return null;		
	}

	public void setIotype(String iotype) {
		this.put("IOTYPE", iotype);
	}

	public String getName() {	
		Object tempdata = this.get("NAME");
		if (tempdata != null) {
			return (String) tempdata;
		}
		
		return null;
	}

	public void setName(String name) {
		this.put("NAME", name);
	}

	public List<Integer> getPositions() {
		return positions;
	}

	public Object getValue() {
		return this.get("VALUE");
	}

	public void setValue(Object value) {
		this.put("VALUE", value);
	}

	public enum ParamType {
		in, out, inout
	}
}
